//
//  SecurityCenterViewModel.swift
//  Exchange
//
//  Created by 孟祥群 on 2018/4/18.
//  Copyright © 2018年 common. All rights reserved.
//

import UIKit

class SecurityCenterViewModel: BaseViewModel {
    var stateArr:[AnyObject] = []
    var model:SecurityModel = SecurityModel()
    lazy var request: SecurityRequest = {
        let api = SecurityRequest()
        api.dataReformer = self
        api.paramSource = self
        api.delegate = self
        return api
    }()
    
    override init(controller: BaseViewController) {
        super.init(controller: controller)
    }
    
    func archiveStates(row:Int) -> String {
        var string = ""
        switch row {
        case 0:
            string = kText("已设置")
            break
        case 1:
            if (model.isMobileBind) {
                string =  (model.mobile.changePhoneNumber())
            }else {
                string = kText("未设置")
            }
            break
        case 2:
            if (model.isTradePwd) {
                string  =  kText("已设置")
            }
            else {
                string = kText("未设置")
            }
            break
        case 3:
            if (model.isGoogleBind) && (model.isOpenGoogle)  {
                string = kText("已开启")
            }
            else if !(model.isGoogleBind){
                string = kText("未绑定")
            }else {
                string = kText("未开启")
            }
            break
        case 4:
            if (model.isEmailBind) {
                string = (model.email.changeEmail())
            }
            else {
                string = kText("未设置")
            }
            break
        case 5:
            AppSecurityInfo.default.readDic()
            if AppSecurityInfo.default.passWordDic[AppSecurityInfo.SecurityInfo.openScreenKey] == "1" {
                string = kText("已开启")
            }else {
               string = kText("未开启")
            }
            break
        case 6:
            if model.seniorAuth == 0 {
                if !model.primaryAuth {
                    return kText("未认证")
                }else {
                   return kText("已初级认证")
                }
            }else if model.seniorAuth == 1 {
                return kText("审核中")
            }else if model.seniorAuth == 2 {
                return kText("未通过")
            }else if model.seniorAuth == 3 {
                return kText("已认证")
            }
            break
        default:
            break
        }
     
        return string
    }
    
}
extension SecurityCenterViewModel: RequestCallBack,RequestDataReformer,RequestParamSource {
    func reform(_ request: BaseRequest, _ data: [String : Any]?) {
        if successBlock != nil {
            successBlock!(data)
        }
    }
    
    func requestDidSucess(_ request: BaseRequest) {
        
    }
    
    func requestDidFail(_ request: BaseRequest) {
        if failBlock != nil {
            failBlock!(request)
        }
    }
    
    func requestParams(_ request: BaseRequest) -> [String : Any]? {
        let pramas: [String:Any] = [:]
        
        return pramas
    }



}
